package com.lwj.liwanjia.view.fragment.supermarket;


import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.lwj.liwanjia.R;
import com.lwj.liwanjia.adapter.ShangpinJiesaoAdapter;
import com.lwj.liwanjia.base.BaseFragment;
import com.superrecycleview.superlibrary.recycleview.SuperRecyclerView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;


/**
 * 商品描述
 */
public class MiaoShuFragment extends BaseFragment {

    public static MiaoShuFragment getInstance(ArrayList<String> imagesList, int imgWidth, int imgHeight) {
        MiaoShuFragment fragment = new MiaoShuFragment();
        Bundle bundle = new Bundle();
        bundle.putStringArrayList("images", imagesList);
        bundle.putInt("imgHeight", imgHeight);
        bundle.putInt("imgWidth", imgWidth);
        fragment.setArguments(bundle);
        return fragment;
    }

    @BindView(R.id.miaoshu_rlv)
    SuperRecyclerView miaoshuRlv;

    private ShangpinJiesaoAdapter adapter;
    private List<String> imagesList = new ArrayList<>();
    private int imgHeight;
    private int imgWidth;

    @Override
    protected void initView(View view) {
        Bundle bundle = getArguments();
        if (bundle != null) {
            imagesList.addAll(bundle.getStringArrayList("images"));
            imgHeight = bundle.getInt("imgHeight");
            imgWidth=bundle.getInt("imgWidth");
        }
        LinearLayoutManager manager = new LinearLayoutManager(getActivity());
        manager.setOrientation(LinearLayoutManager.VERTICAL);
        miaoshuRlv.setLayoutManager(manager);
        miaoshuRlv.setRefreshEnabled(false);
        miaoshuRlv.setLoadMoreEnabled(false);
        adapter = new ShangpinJiesaoAdapter(getActivity(), imagesList,imgWidth,imgHeight);
        miaoshuRlv.setAdapter(adapter);
    }

    @Override
    protected void initData() {
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_miao_shu;
    }


}
